<template>
</template>

<script>

export default {
  name: "redirect",
  data() {
    return {
      loading: false,
      targetUrl: ''
    };
  },
  created() {
    this.handleLogin();
  },
  methods: {
    handleLogin() {
      this.loading = true;
      let roleIds = '8';
      //todo get router 目前不用 多一次请求调用
      //获取地址参数
      var queryParams = this.$route.query;
      // 如果 URL 中有 redirect 参数，则设置到 targetUrl
      if (queryParams.url) {
        this.targetUrl = queryParams.url;
      }

      this.$store.dispatch("QuickLogin", roleIds).then(() => {
        this.$router.push({ path: this.targetUrl || "/index" }).catch(() => { });
      }).catch(() => {
        this.loading = false;
      });
    }
  }
};
</script>